package com.CNMedical.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.CNMedical.system.domain.entity.AppletForumCollect;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.CNMedical.common.annotation.Log;
import com.CNMedical.common.core.controller.BaseController;
import com.CNMedical.common.core.domain.AjaxResult;
import com.CNMedical.common.enums.BusinessType;
import com.CNMedical.system.service.IAppletForumCollectService;
import com.CNMedical.common.utils.poi.ExcelUtil;
import com.CNMedical.common.core.page.TableDataInfo;

/**
 * 论坛帖子收藏Controller
 * 
 * @author tang
 * @date 2023-04-01
 */
@RestController
@RequestMapping("/system/forumCollect")
public class AppletForumCollectController extends BaseController
{
    @Autowired
    private IAppletForumCollectService appletForumCollectService;

    /**
     * 查询论坛帖子收藏列表
     */
    @PreAuthorize("@ss.hasPermi('system:forumCollect:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletForumCollect appletForumCollect)
    {
        startPage();
        List<AppletForumCollect> list = appletForumCollectService.selectAppletForumCollectList(appletForumCollect);
        return getDataTable(list);
    }

    /**
     * 导出论坛帖子收藏列表
     */
    @PreAuthorize("@ss.hasPermi('system:forumCollect:export')")
    @Log(title = "论坛帖子收藏", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppletForumCollect appletForumCollect)
    {
        List<AppletForumCollect> list = appletForumCollectService.selectAppletForumCollectList(appletForumCollect);
        ExcelUtil<AppletForumCollect> util = new ExcelUtil<AppletForumCollect>(AppletForumCollect.class);
        util.exportExcel(response, list, "论坛帖子收藏数据");
    }

    /**
     * 获取论坛帖子收藏详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:forumCollect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appletForumCollectService.selectAppletForumCollectById(id));
    }

    /**
     * 新增论坛帖子收藏
     */
    @PreAuthorize("@ss.hasPermi('system:forumCollect:add')")
    @Log(title = "论坛帖子收藏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletForumCollect appletForumCollect)
    {
        return toAjax(appletForumCollectService.insertAppletForumCollect(appletForumCollect));
    }

    /**
     * 修改论坛帖子收藏
     */
    @PreAuthorize("@ss.hasPermi('system:forumCollect:edit')")
    @Log(title = "论坛帖子收藏", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletForumCollect appletForumCollect)
    {
        return toAjax(appletForumCollectService.updateAppletForumCollect(appletForumCollect));
    }

    /**
     * 删除论坛帖子收藏
     */
    @PreAuthorize("@ss.hasPermi('system:forumCollect:remove')")
    @Log(title = "论坛帖子收藏", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletForumCollectService.deleteAppletForumCollectByIds(ids));
    }
}
